package com.cqhfan.contentservice.controller;

import com.cqhfan.contentservice.service.WorksService;
import com.cqhfan.core.domain.dto.PageDTO;
import com.cqhfan.core.domain.query.PageQuery;
import com.cqhfan.pojo.content.dto.AddWorksDTO;
import com.cqhfan.pojo.content.po.Works;
import com.cqhfan.pojo.content.query.NearWorksQuery;
import com.cqhfan.pojo.content.query.ProfileWorksQuery;
import com.cqhfan.pojo.content.vo.ProfileWorksVO;
import com.cqhfan.pojo.content.vo.WorksVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 眭传洪
 * @create 2025-08-01 0:33
 */
@RestController
@RequestMapping("/works")
@RequiredArgsConstructor
public class WorksController {

    private final WorksService worksService;

    /**
     * 添加作品
     */
    @PostMapping("/addWorks")
    public void addWorks(@RequestBody AddWorksDTO body) {
        worksService.addWorks(body);
    }

    /**
     * 推荐列表
     */
    @GetMapping("/pageByRecommend")
    public PageDTO<WorksVO> listByRecommend(PageQuery query) {
        return worksService.pageByRecommend(query);
    }

    /**
     * 关注列表
     */
    @GetMapping("/pageByFollow")
    public PageDTO<WorksVO> listByFollow(PageQuery query) {
        return worksService.pageByFollow(query);
    }

    /**
     * 朋友列表
     */
    @GetMapping("/pageByFriend")
    public PageDTO<WorksVO> listByFriend(PageQuery query) {
        return worksService.pageByFriend(query);
    }

    /**
     * 附近列表
     */
    @GetMapping("/pageByNear")
    public PageDTO<WorksVO> listByNear(NearWorksQuery query) {
        return worksService.pageByNear(query);
    }

    /**
     * 个人中心作品列表
     */
    @GetMapping("/pageByUserId")
    public PageDTO<ProfileWorksVO> listByUserId(ProfileWorksQuery query) {
        return worksService.pageByUserId(query);
    }

    /**
     * 作品详情，从个人中心进去的接口
     */
    @GetMapping("/viewWorks/{worksId}")
    public WorksVO singleWorks(@PathVariable("worksId") Long worksId) {
        return worksService.viewWorks(worksId);
    }

    /**
     * 未登录时推荐页面查询
     */
    @GetMapping("/pageByRecommendForGuest")
    public PageDTO<WorksVO> listByRecommendForGuest(PageQuery query) {
        return worksService.pageByRecommendForGuest(query);
    }

    @GetMapping("/getByWorksId/{worksId}")
    public Works getByWorksId(@PathVariable("worksId") Long worksId) {
        return worksService.getByWorksId(worksId);
    }

}
